* sample_choice_desocupados.do	JEP 05/01/15
* Choose sample of desocupados

*************************** Change log ********************************** 
/*
	
*/
cap program drop mysample_desocupados
program mysample_desocupados
	syntax newvarname , sex(integer) edadm(integer) [exind(numlist)]
	tempvar sex_s edad_s cat 
	
	if "`exind'"!=""{
		local cexind : subinstr local exind " " ",", all
		* Notice I am using trabajoo instead of buscado because buscado is missing for 2000q3, 2000q4
		keep if !inlist(ctrabajoo_actividad,`cexind') | !inlist(cbuscado_actividad,`cexind')
	}
	
		if `sex'==0 gen `sex_s'=1
	else gen `sex_s' = (sex==`sex')
	gen `edad_s' = (cedad<=`edadm')
	
	* Generate sample variable
	
	gen `varlist' =  (`sex_s' & `edad_s')
end
	





